package controllers

import (
	"fmt"
	"gcopyright/repositories"
	"gcopyright/service"
	"os"
)

type UserController struct {
	Common
}

func NewUserController() *UserController {
	return &UserController{}
}

func (u *UserController) GetLogin() { //登录
	sql := repositories.NewRepositoriesSqlite()
	l := service.NewLoginService(u.Ctx)
	u.Common.ReturnSuccess(l.Login(sql))
}

func (u *UserController) GetSql() { // 测试路由，后期删除
	sql := repositories.NewRepositoriesSqlite()
	//array,_:= sql.QuernEtherTableAccountsFrequency("0x0001")
	//sql.InsertBalanceTable()
	//array := sql.QuernAccountBalanceFor7("0x09d3146906c7f39347dd977d303ad36e2a1186f6")
	sql.CreateEtherTable()
	fmt.Println("end ")
	u.ReturnSuccess("yes")
}

func (u *UserController) GetEnv() {
	eth := os.Getenv("ETHER")
	fmt.Println(eth)
	u.ReturnSuccess(eth)
}

func (u *UserController) GetDeployaddress() {
	sol := service.NewSolService(u.Ctx)
	u.ReturnSuccess(sol.QuerToken(u.Ctx.URLParam("address")))
}
